package cn.wolfcode.wms.service.impl;

import cn.wolfcode.wms.domain.SystemMenu;
import cn.wolfcode.wms.mapper.SystemMenuMapper;
import cn.wolfcode.wms.query.QueryObject;
import cn.wolfcode.wms.service.ISystemMenuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class SystemMenuServiceImpl implements ISystemMenuService {
    @Autowired
    private SystemMenuMapper systemMenuMapper;
    public void save(SystemMenu systemMenu) {
        systemMenuMapper.insert(systemMenu);
    }

    public void update(SystemMenu systemMenu) {
        systemMenuMapper.updateByPrimaryKey(systemMenu);
    }

    public void delete(Long id) {
        systemMenuMapper.deleteByPrimaryKey(id);
    }

    public SystemMenu get(Long id) {
        return systemMenuMapper.selectByPrimaryKey(id);
    }

    public List<SystemMenu> list() {
        return systemMenuMapper.selectAll();
    }

    public PageInfo<SystemMenu> query(QueryObject qo) {
        //        调用分页包
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<SystemMenu> list = systemMenuMapper.queryForList(qo);
        return new PageInfo<SystemMenu>(list);
    }

    public SystemMenu selectByParentId(Long parentId) {
        return systemMenuMapper.selectByPrimaryKey(parentId);
    }

    public List<Map<String, Object>> selectByParentSn(String parentSn) {
        return systemMenuMapper.selectByParentSn(parentSn);
    }

    public List<Map<String, Object>> selectByEmployeeId(String parentSn, Long employeeId) {
        return systemMenuMapper.selectByEmployeeId(parentSn,employeeId);
    }
}
